//
//  Utils.h
//  ChatDemo-UI2.0
//
//  Created by li.guibin on 15/11/30.
//  Copyright © 2015年 li.guibin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

@interface Utils : NSObject

#pragma -- GET 网络请求

+(BOOL)get:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id jsonObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;

+(BOOL)post:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id jsonObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;
+ (void)POST:(NSString *)url parameters:(NSDictionary *)params constructingBodyWithBlock:(void (^)(id<AFMultipartFormData>))block success:(void (^)(id))success failure:(void (^)(NSError *))failure;
+ (void)POSTApliy:(NSString *)url parameters:(NSDictionary *)params constructingBodyWithBlock:(void (^)(id<AFMultipartFormData>))block success:(void (^)(id))success failure:(void (^)(NSError *))failure;

#pragma -- PACKAGE PARAMETERS
+ (NSMutableDictionary *)completeImageSubmitParameterWith:(NSMutableDictionary *)originalParameter;
+ (NSMutableDictionary *)completeParameterWith:(NSMutableDictionary *)originalParameter;
+ (NSString *)getXMLStringWithParameter:(NSMutableDictionary *)origianlDict;
#pragma -- GET SIGN VALUE
+ (NSString *)urlWithSignValue:(NSDictionary*)dict;
//#pragma -- PERSONEAL IMFORMATION SOTRE&ACQUIRE
//+ (BOOL)personalImformationSaveWtih:(NSDictionary *)imformation;
+ (NSDictionary *)acquirePersonalImformationFromMemoryWithPersonID:(NSString *)personalID;
#pragma -- 转码
+ (NSString*)URLencode:(NSString *)originalString stringEncoding:(NSStringEncoding)stringEncoding;
+(NSString *) encodeUrlStr:(NSString *)sourceString;
#pragma -- XMLParse
+ (id)parseXMLWithResposeData:(NSData *)resposeData;

+ (void)alertViewWithMessage:(NSString *)message;
+ (NSString *)MD5EncryptWith:(NSString *)originalStr;
+ (NSString *)getStringByDate:(NSDate *)date;
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;
+ (UIColor *)colorWithHexString:(NSString *)color;
+ (NSUInteger)transformStringToNsinterger:(NSString *)dateStr;
+(void)hasMobile:(id)delegate andFunc:(NSString *)func;
/**
 *  压缩图片
 *  @param image   图片
 *  @return 压缩好的图片
 */
+(UIImage *)imageWithImage:(UIImage *)image;

/**
 *  用于判断字符串中是否含有表情
 *
 *  @param string 传入的字符串
 *
 *  @return bool类型
 */
+ (BOOL)stringContainsEmoji:(NSString *)string;

/**
 *  返回一段字符串的高度
 *
 *  @param str 传入的字符串
 *
 *  @return 字符串的size
 */
+(CGSize )labelSizeWithStr:(NSString *)str andWidth:(CGFloat)width andFont:(CGFloat)font;
+(CGFloat)resizeContentLabelHeightWithString:(NSString *)str andLineSpacing:(CGFloat)space andFont:(UIFont *)font andMaxWidth:(CGFloat)maxWidth;

///*
// *  计算字符串尺寸
// */
//+ (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize lineBreakMode:(NSLineBreakMode)lineBreakMode;

/**
 *  修改时间
 *
 *  @param str 传入时间
 *
 *  @return 1 代表今天 2 代表昨天前 3 代表跨年
 */
+(NSString *)getProperDataStringWithString:(NSString *)str;

/**
 *  检查当前网络环境状态
 *
 */
+(void)checkNetStateWithBlock:(void(^)(int type))block;
/**
 *  云盘时间显示
 *
 *  @param str <#str description#>
 *
 *  @return <#return value description#>
 */
+(NSString *)getDataStringWithString:(NSString *)str;

/**
    当天只显示时分，隔天显示月日时分，跨年显示年月日时分
 */
+(NSString *)getDataStringWithoutSecondString:(NSString *)str;
/**
 *  判断状态，从后台返回前台时候调用下
 */
+(void)judgeState;

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;

+(void)hideHUD;
+(void)showHUD;
/*
 *获取当前视图控制器
 */
+(UIViewController *)getCurrentVC;
//获取当前时间
+ (NSString *)getCurrentTime;

//判断是否为空字符串
+ (BOOL) isBlankString:(NSString *)string;
/*
 * @Sylar
 *
 * 16进制字符串生成颜色对象.   e.g #FF0011 = (255,0,17)
 */
UIColor* colorFromHex(NSString * hexString);

/*
 * @Sylar
 *
 * 16进制字符串生成颜色对象,alpha 透明度alpha < 1.0
 */
UIColor* colorFromHexAndAlpha(NSString * hexString,CGFloat alpha);

/**清理webview缓存,退出登录时候手动清理一下webview缓存*/
+ (void)clearWebViewCache;

+(UIColor *)stringToColor: (NSString *) stringToConvert;

/*
 * @Sylar
 *
 * 关键字搜索
 */
+(NSMutableArray *)getRangeStr:(NSString *)text findText:(NSString *)findText;

+(void)resaePersonadataWithLogo:(NSString *)url;
+ (NSString*)dictionaryToJson:(NSDictionary *)dic;

+ (NSString*)weekdayStringFromDate:(NSDate*)inputDate;

+(void)resaePersonadataWithBacePic:(NSString *)imageId;

//存储用户信息
+ (void)starageData:(NSDictionary *)dictionary;
//字符串转时间戳 年月日时分
+ (NSString *)time_timestampToString:(NSString *)timesStr;
//年月日
+ (NSString *)time_timestampToString2:(NSString *)timesStr;
@end
